package com.sxu.demo;

import java.time.LocalTime;
import java.util.concurrent.*;

public class Test3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService pool = Executors.newFixedThreadPool(2);
        Future<String> future = pool.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                System.out.println( "running...");
                Thread.sleep(5000);
                return "ok";
            }
        });
        System.out.println("before submit" + LocalTime.now());
        System.out.println(future.get());
        System.out.println("after submit" + LocalTime.now());
    }
}
